package com.xbongbong.saas.model.impl;

import com.xbongbong.paas.toolbox.util.DateUtil;
import com.xbongbong.saas.domain.dao.KnowledgeBaseDao;
import com.xbongbong.saas.domain.entity.KnowledgeBaseEntity;
import com.xbongbong.saas.model.KnowledgeBaseModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Author mingliang
 * @Description 知识库Model
 * @Date 2022/6/21 15:14
 **/
@Service("knowledgeBaseModel")
public class KnowledgeBaseModelImpl implements KnowledgeBaseModel {
    @Resource
    private KnowledgeBaseDao knowledgeBaseDao;

    @Override
    public Integer insert(KnowledgeBaseEntity entity) {
        long now = DateUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        return knowledgeBaseDao.insert(entity);
    }

    @Override
    public void insertBatch(List<KnowledgeBaseEntity> list) {
        knowledgeBaseDao.insertBatch(list);
    }

    @Override
    public List<KnowledgeBaseEntity> findEntitys(Map<String, Object> param) {
        return knowledgeBaseDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return knowledgeBaseDao.getEntitysCount(param);
    }

    @Override
    public Integer update(KnowledgeBaseEntity entity) {
        long now = DateUtil.getInt();
        entity.setUpdateTime(now);
        return knowledgeBaseDao.update(entity);
    }

    @Override
    public KnowledgeBaseEntity getByKey(Long key, String corpid) {
        return knowledgeBaseDao.getByKey(key, corpid);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return knowledgeBaseDao.findEntitys(param);
    }

    @Override
    public Integer updateBatch(List<KnowledgeBaseEntity> knowledgeBaseEntityList, String corpid) {
        return knowledgeBaseDao.updateBatch(knowledgeBaseEntityList, corpid);
    }
}
